package com.system.zuulserver.config;

import org.springframework.cloud.netflix.zuul.filters.RouteLocator;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;

@Primary
@Component
public class DocumentationConfig implements SwaggerResourcesProvider {
    private final RouteLocator routeLocator;

    public DocumentationConfig(RouteLocator routeLocator) {
        this.routeLocator = routeLocator;
    }


    @Override
    public List<SwaggerResource> get() {
        List resources = new ArrayList<>();
        resources.add(swaggerResource("用户服务", "/user/v2/api-docs", "2.0"));
        resources.add(swaggerResource("公共服务", "/common/v2/api-docs", "2.0"));
        resources.add(swaggerResource("商品类别服务", "/goodstype/v2/api-docs", "2.0"));
        resources.add(swaggerResource("收藏服务", "/collect/v2/api-docs", "2.0"));
        resources.add(swaggerResource("优惠券服务", "/coupon/v2/api-docs", "2.0"));
        resources.add(swaggerResource("商品需求服务", "/goodsneed/v2/api-docs", "2.0"));
        resources.add(swaggerResource("商品服务", "/goods/v2/api-docs", "2.0"));
        resources.add(swaggerResource("积分服务", "/integral/v2/api-docs", "2.0"));
        resources.add(swaggerResource("订单服务", "/order/v2/api-docs", "2.0"));
        resources.add(swaggerResource("品牌服务", "/brands/v2/api-docs", "2.0"));
        resources.add(swaggerResource("库存服务", "/stockservice/v2/api-docs", "2.0"));
        resources.add(swaggerResource("授权服务", "/oauthserver/v2/api-docs", "2.0"));
        return resources;
    }


    private SwaggerResource swaggerResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }

}
